package lab01;
import java.util.Scanner;
public class Test012 {
    public static void main(String args[]) {
        int number = 0, n5, n4, n3, n2, n1;
        System.out.println("请输入一个数：");
        Scanner input = new Scanner(System.in);
        number = input.nextInt();
        if (number >= 1 || number <= 99999)//判断number在1至99999之间的条件  
        {
            n5 = number / 10000;//计算number的最高位（万位）n5  
            n4 = number % 10000 / 1000;//计算number的千位n4  
            n3 = number % 10000 % 1000 / 100;//计算number的百位n3  
            n2 = number % 100 / 10;//计算number的十位n2
            n1 = number % 10;//计算number的个位n1 
            if (n5 >= 1 && n5 <= 9)//判断number是5位数的条件  
            {
                System.out.println(number + "是5位数");
                if (n1 == n5 && n2 == n4)//判断number是回文数的条件  
                {
                    System.out.println(number + "是回文数");
                } else {
                    System.out.println(number + "不是回文数");
                }
            } else if (n5 == 0 && (n4 >= 1 && n5 <= 9)) //判断number是4位数的条件  
            {
                System.out.println(number + "是4位数");
                if (n1 == n4 && n2 == n3)//判断number是回文数的条件
                {
                    System.out.println(number + "是回文数");
                } else {
                    System.out.println(number + "不是回文数");
                }
            } else if (n5 == 0 && n4 == 0 && n3 != 0) //判断number是3位数的条件  
            {
                System.out.println(number + "是3位数");
                if (n1 == n3) //判断number是回文数的条件  
                {
                    System.out.println(number + "是回文数");
                } else {
                    System.out.println(number + "不是回文数");
                }
            } else if (n2 != 0) {
                System.out.println(number + "是2位数");
                if (n1 == n2) {
                    System.out.println(number + "是回文数");
                } else {
                    System.out.println(number + "不是回文数");
                }
            } else if (n1 != 0) {
                System.out.println(number + "是1位数");
                System.out.println(number + "是回文数");
            }
        } else {
            System.out.printf("\n%d不在1至99999之间", number);
        }
    }
}



